import{g as b}from"./translation.js";import{d as y,e as u,r as h,o as _,aa as w,P as D,Q as k,$ as l,X as o,a4 as d,K as n,aE as c,N as x,R as p,b4 as B,a2 as S,a5 as A}from"./elementPlusModules.js";const E={style:{"margin-top":"10px",height:"30vh","background-color":"rgba(0, 0, 0, 0.3)"}},T={style:{"text-align":"center"}},M=y({__name:"Context",setup(V){const v=u(`
<template>
  <el-button type="primary" @click="visible = true">编辑</el-button>
  <div v-loading="status.page" style="margin-top: 10px; height: 30vh; background-color: rgba(0, 0, 0, 0.3)"></div>
  <el-dialog v-model="visible" title="编辑">
    <div style="text-align: center">
      <el-button type="primary" :loading="status.button" @click="handleSaveBtn">保存</el-button>
    </div>
  </el-dialog>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from "vue";

import { ElButton, ElDialog } from "element-plus";

import { getAllTranslationHeadApi } from "../../../../../api/modules/sysManage/translation";

const visible = ref(false);

const status = reactive({
  page: false,
  button: false
});

// 获取页面数据
const queryData = async () => {
  // 真实接口案例
  status.page = true;
  const res = await getAllTranslationHeadApi({} as FormData);
  status.page = false;
  return res.data;
};
// 保存数据
const handleSave = () => {
  return new Promise(resolve => {
    status.button = true;
    setTimeout(() => {
      status.button = false;
      resolve({});
    }, 1000);
  });
};

// 保存按钮
const handleSaveBtn = async () => {
  // 调用保存接口
  await handleSave();
  // 关闭模态框
  visible.value = false;
  // 刷新页面
  await queryData();
};

onMounted(() => queryData());
<\/script>
`),a=u(!1),e=h({page:!1,button:!1}),r=async()=>{e.page=!0;const t=await b({});return e.page=!1,t.data},m=()=>new Promise(t=>{e.button=!0,setTimeout(()=>{e.button=!1,t({})},1e3)}),g=async()=>{await m(),a.value=!1,await r()};return _(()=>r()),(t,s)=>{const f=w("loading");return D(),k(A,null,[l(n(c),{type:"primary",onClick:s[0]||(s[0]=i=>a.value=!0)},{default:o(()=>[d("编辑")]),_:1}),x(p("div",E,null,512),[[f,e.page]]),l(n(B),{modelValue:a.value,"onUpdate:modelValue":s[1]||(s[1]=i=>a.value=i),title:"编辑"},{default:o(()=>[p("div",T,[l(n(c),{type:"primary",loading:e.button,onClick:g},{default:o(()=>[d("保存")]),_:1},8,["loading"])])]),_:1},8,["modelValue"]),S(t.$slots,"default",{html:v.value})],64)}}});export{M as _};
